import Operator from "./Operator";
import {RC} from "../config/RC";
import jwt from "jsonwebtoken"
import OperateArgs from "./OperateArgs";
import {SECRET} from "../config/config";



class JwtGenerateOperator extends Operator{
    public async execute(): Promise<RC> {
        const userId: string = this.args.getProperty("userId");
        const token = jwt.sign({userId: userId}, SECRET, {expiresIn: '1h'});
        this.args.setProperty("token", token);
        return RC.SUCCESS;
    }
}

export default JwtGenerateOperator;